package datahandling;
import java.io.*;
import java.util.regex.*;
import java.util.*;


public class FileStore{
    public final ArrayList<String> dirStrArr = new ArrayList<String>();//待处理文件池
	public FileStore(String path) throws Exception{
		File dirFile = new File(path);
		if(dirFile.exists()){
			File files[] = dirFile.listFiles();//遍历文件夹
			for(File file : files){
				String pattern = ".*labelAt.*";
				boolean isMatch = Pattern.matches(pattern, file.getName()); //判断文件名是否符合要求
				if(isMatch){
					//符合条件则将数组加入list
					dirStrArr.add(file.getAbsolutePath());  
				}
			}
		}
		else{
	        System.out.println("there have no this dir");  
		}
	}
	
	public static void main(String[] args) throws Exception {
        System.out.println("input the absolutely path of files:");
		Scanner in = new Scanner(System.in);
        String path = in.nextLine();
		FileStore allFile = new FileStore(path);
		
		//遍历读文件
		for(String str : allFile.dirStrArr){
			new TxtFile(str);
		}
        System.out.println("input the out path(dir):");
        String outPath = in.nextLine();
        Label.writeFile(outPath);

		in.close();
	}
	
}
